<template>
	<view class="goods-list">
		<view v-if="type === 'double'" class="goods-double row-between">
			<navigator v-for="(item, index) in list" :key="index" class="item bg-white mt20" hover-class="none" open-type="navigate"
			 :url="'/package_goods/pages/goods_detail/index?id=' + (isBargain ? item.goods_id : item.id)">
				<view class="goods-img" style="width: 347rpx;height:347rpx;">
					<custom-image :lazy-load="true" width="347rpx" height="347rpx" radius="10rpx" lazy-load :src="item.image"></custom-image>
				</view>
				<view class="goods-info">
					<view class="goods-name line2">{{item.name}}</view>
					<view class="price mt10 row">
						<price-format color="#FF2C3C"  class="mr10" :first-size="34" :second-size="26" :subscript-size="26" :price="item.price" :weight="500"></price-format>
						<price-format class="muted" :firstSize="24" :secondSize="24" :subscript-size="24" line-through :price="item.market_price || item.activity_price"></price-format>
					</view>
				</view>
			</navigator>
		</view>
		<view v-if="type === 'hot'" class="goods-hot">
			<navigator v-for="(item, index) in list" :key="index" class="item bg-white mt20 row" hover-class="none" open-type="navigate"
			 :url="'/package_goods/pages/goods_detail/index?id=' + item.id">
				<view class="goods-img" style="width: 180rpx;height:180rpx;">
					<custom-image :lazy-load="true" width="180rpx" height="180rpx" radius="6rpx" lazy-load :src="item.image"></custom-image>
				</view>
				<view class="goods-info ml20">
					<view class="goods-name line2 mb10">{{item.name}}</view>
					<text class="sale br60 xxs">已有{{item.sales_sum}}人购买</text>
					<view class="row-between  mt10">
						<view class="price mt10 row">
							<price-format color="#FF2C3C"  class="mr10" :first-size="34" :second-size="26" :subscript-size="26" :price="item.price" :weight="500"></price-format>
							<price-format class="muted" :firstSize="24" :secondSize="24" :subscript-size="24" line-through :price="item.market_price"></price-format>
						</view>
						<image class="icon-md" src="/static/images/icon_go_red.png"></image>
					</view>
				</view>
				<image class="paixu" :src="'/static/images/No.' + (index < 3 ? index : 3) + '.png'"></image>
				<view class="number xxs">{{ index + 1 }}</view>
			</navigator>
		</view>
		<view v-if="type === 'home-hot'" class="goods-home-hot goods-hot">
			<navigator v-for="(item, index) in list" :key="index" class="item bg-white mb20 row" hover-class="none" open-type="navigate"
			 :url="'/package_goods/pages/goods_detail/index?id=' + item.id">
				<view class="goods-img">
					<custom-image :lazy-load="true" width="240rpx" height="240rpx" radius="6rpx" lazy-load :src="item.image"></custom-image>
				</view>
				<view class="goods-info ml20 mr20">
					<view class="goods-name line2 mb10">{{item.name}}</view>
					<text class="sale br60 xxs" v-if="itemType === 'gm'">“已有{{item.sales_sum}}次购买”</text>
					<text class="sale br60 xxs" v-else-if="itemType === 'zl'">“已有{{item.sales_sum}}次租赁”</text>
					<view class="row-between  mt10">
						<view class="price mt10 row" v-if="itemType === 'gm'">
							<price-format color="#FF2C3C" :first-size="34" :second-size="26" :subscript-size="26" :price="item.price" :weight="500"></price-format>
							<price-format class="muted" delNum :firstSize="24" :secondSize="24" :subscript-size="24" line-through :price="item.market_price"></price-format>
						</view>
						<view class="price mt10 row zl" v-else-if="itemType === 'zl'">
							<view class="yj-box">
								<view class="label">押</view>
								<view class="p">
								<price-format color="#FF2C3C" :first-size="24" :second-size="24" :subscript-size="24" :price="item.price" :weight="500"></price-format>
								</view>
							</view>
							<view class="day-text">
								￥<view class="d">20</view>.22/天
							</view>
						</view>
						<!-- #ifndef MP-ALIPAY -->
						<button type="primary" class="br60" size="xs">马上抢</button>
						<!-- #endif -->
						<!-- #ifdef MP-ALIPAY -->
						<view class="br60 alipay-button">马上抢</view>
						<!-- #endif -->
					</view>
				</view>
				<image class="paixu" :src="'/static/images/No.' + (index < 3 ? index : 3) + '.png'"></image>
				<view class="number">{{ index + 1 }}</view>
			</navigator>
		</view>
		<view v-if="type === 'store-detail'" class="goods-home-hot goods-hot">
			<navigator v-for="(item, index) in list" :key="index" class="item bg-white mb20 row" hover-class="none" open-type="navigate"
			 :url="'/package_goods/pages/goods_detail/index?id=' + item.id">
				<view class="goods-img">
					<custom-image :lazy-load="true" width="240rpx" height="240rpx" radius="6rpx" lazy-load :src="item.image"></custom-image>
				</view>
				<view class="goods-info ml20 mr20">
					<view class="goods-name line2 mb10">
						<text class="tag">已租</text>
					<text>{{item.name}}</text>
					</view>
					<text class="sale br60 xxs">“已有{{item.sales_sum}}次租赁”</text>
					<view class="row-between  mt10">
						<view class="price mt10 row zl">
							<view class="yj-box">
								<view class="label">押</view>
								<view class="p">
								<price-format color="#FF2C3C" :first-size="24" :second-size="24" :subscript-size="24" :price="item.price" :weight="500"></price-format>
								</view>
							</view>
							<view class="day-text">
								￥<view class="d">20</view>.22/天
							</view>
						</view>
						<button type="primary" class="br60" size="xs">马上抢</button>
					</view>
				</view>
				
			</navigator>
		</view>
		<view v-if="type === 'new'" class="goods-new">
			<navigator v-for="(item, index) in list" :key="index" class="item bg-white mt20 row" hover-class="none" open-type="navigate"
			 :url="'/package_goods/pages/goods_detail/index?id=' + item.id">
				<view class="goods-img">
					<custom-image :lazy-load="true" width="240rpx" height="240rpx" radius="10rpx" lazy-load :src="item.image"></custom-image>
				</view>
				<view class="goods-info ml20 mr20 flex1">
					<view class="goods-name line2 mb20">{{item.name}}</view>
					<view class="row-between muted xxs ">
						<view class="line-through">
							<text>原价</text>
							<price-format :second-size="22" :first-size="22" :subscript-size="22" :price="item.market_price"></price-format>
						</view>
						<view>{{item.sales_sum}}人购买</view>
					</view>
					<view class="row-between  mt10">
						<price-format color="#FF2C3C" :first-size="38" :subscript-size="26"  :second-size="26" :price="item.price"
						 :weight="500"></price-format>
						 <!-- #ifndef MP-ALIPAY -->
						 <button type="primary" class="br60" size="xs">立即抢购</button>
						 <!-- #endif -->
						 <!-- #ifdef MP-ALIPAY -->
						 <view class="br60 alipay-button">立即抢购</view>
						 <!-- #endif -->
					</view>
				</view>
			</navigator>
		</view>
		<view v-if="type === 'one'" class="goods-one mt20">
			<navigator v-for="(item, index) in list" :key="index" class="item bg-white row" hover-class="none" open-type="navigate"
			 :url="'/package_goods/pages/goods_detail/index?id=' + item.id">
				<view class="goods-img" style="width: 200rpx;height:200rpx;">
					<custom-image :lazy-load="true" width="200rpx" height="200rpx" radius="6rpx" lazy-load :src="item.image"></custom-image>
				</view>
				<view class="goods-info ml20">
					<view class="goods-name line2 mb10">{{item.name}}</view>
					<view class="row-between mt10">
						<view class="price mt10 row">
							<price-format color="#FF2C3C"  class="mr10" :first-size="34" :second-size="26" :subscript-size="26" :price="item.price" :weight="500"></price-format>
							<price-format class="muted" :firstSize="24" :secondSize="24" :subscript-size="24" line-through :price="item.market_price"></price-format>
						</view>
					</view>
				</view>
			</navigator>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			type: {
				type: String,
				default: 'double'
			},
			itemType: {
				type: String,
				default: 'zl'
			},
			list: {
				type: Array,
				default: () => []
			},
            isBargain: {
                type: Boolean,
                default: false
            }
		},
		data() {
			return {

			};
		}
	}
</script>

<style lang="scss" scoped>
	.goods-list {
		.goods-double {
			flex-wrap: wrap;
			padding: 0 20rpx;
			align-items: stretch;
			.item {
				width: 347rpx;
				border-radius: 10rpx;

				.goods-info {
					padding: 10rpx;
				}
			}
		}
		
		.alipay-button {
			padding: 10rpx 20rpx;
			font-size: 26rpx;
			background-color: #24A3FF;
			color: #FFFFFF;
		}
		
		.goods-hot {
			&.goods-home-hot {
				.item {
					padding: 0;
					.paixu,
					.number {
						left: 10rpx;
					}
				}
			}
			.item {
				position: relative;
				padding: 30rpx 20rpx;
				border-radius: 10rpx;
			
				.goods-info {
					width: 450rpx;
					
					.goods-name{
						.tag{
							width: 52rpx;
							height: 32rpx;
							background: #DC4F3F;
							border-radius: 4rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 600;
							font-size: 20rpx;
							color: #FFFFFF;
							line-height: 20rpx;
							display: inline-flex;
							align-items: center;
							justify-content: center;
							margin-right: 8rpx;
						}
					}
			
					.sale {
						padding: 4rpx 18rpx 4rpx 0;
						color: #F79C0C;
						background-color: transparent;
					}
					
					.price{
						display: flex;
						flex-direction: column;
					}
					
					.price.zl{
						
						.yj-box{
							height: 38rpx;
							border-radius: 4rpx;
							border: 1rpx solid #FF2C3C;
							display: flex;
							align-items: center;
							.label{
								width: 38rpx;
								height: 36rpx;
								background-color: #FF2C3C;
								color: #fff;
								font-size: 24rpx;
								display: flex;
								align-items: center;
								justify-content: center;
							}
							.p{
								font-size: 24rpx;
								color: #FF2C3C;
								padding: 0 10rpx;
								display: flex;
								align-items: center;
								justify-content: center;
							}
						}
						.day-text{
							display: flex;
							align-items: flex-end;
							color: #FF2C3C;
							margin-top: 10rpx;
							.d{
								font-weight: 600;
								font-size: 36rpx;
								line-height: 36rpx;
							}
						}
					}
				}
			
				.paixu,
				.number {
					position: absolute;
					top: 0;
					left: 27rpx;
					width: 50rpx;
					height: 54rpx;
					line-height: 60rpx;
					text-align: center;
					color: #621E09;
				}
			}
		} 

		.goods-one .item {
			padding: 20rpx;
			
			&:not(:last-of-type) {
				margin-bottom: 20rpx;
			}
		}
		.goods-new .item {
		    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.16);
		    border-radius: 10rpx;
		}
		
	}
</style>
